<template>
	<view class="content">
		<headerbox :cixitype="cixi"></headerbox>
		<view class="pages">
			<view class="card">
				<view class="card-body" v-if="isBaoxianType==1">
					<view class="title">保险积分余额</view>
					<view class="title1">RMB {{userinfo.fs_money||0.00}}</view>
				</view>
				<view class="card-body" v-if="isBaoxianType==2">
					<view class="title">MY积分余额</view>
					<view class="title1">RMB {{userinfo.money||0.00}}</view>
				</view>
			</view>
			<!-- <view class="filter-section">
				<view class="shaixuan">
					<view class="label">说明</view>
					<select name="description" id="description" v-model="shuoming">
						<option value="0">全部</option>
						<option value="1">充值</option>
						<option value="2">兑换</option>
						<option value="3">单</option>
						<option value="4">Daily Deduct</option>
					</select>
				</view>
				<view class="shaixuan">
					<view class="label">日期</view>
					<select name="description" id="description" v-model="date">
						<option value="0">全部</option>
						<option value="1">今日</option>
						<option value="2">昨日</option>
						<option value="3">本周</option>
						<option value="4">本月</option>
					</select>
				</view>
			</view> -->
			<view class="card" style="margin-top: 60rpx;">
				<view class="card-body" style="padding: 20rpx;" v-if="baoxianList.length==0">
					<h4>未找到记录</h4>
				</view>
				<view id="nav_content_list" v-if="baoxianList.length>0">
					<view class="nav_content_list titleTow">
						<view class="view1">金额</view>
						<view class="view2">变动类型</view>
						<view class="view3">时间</view>
					</view>
					<view class="nav_content_list " v-for="(item,index) in baoxianList" :key="index">
						<view class="view1">{{item.money}}</view>
						<view class="view2">{{item.memo}}</view>
						<view class="view3">{{item.created_at}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="footer-bar" :class="cixi ? '':'footer-bar-detached'">
			<view class="fbitem" @click="goSwichPage('/pages/index/index')">
				<view class="image">
					<image src="../../static/timg/shouye.png" mode=""></image>
				</view>
				<view class="text">首页</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/contract/contract')">
				<view class="image">
					<image src="../../static/timg/heyue.png" mode=""></image>
				</view>
				<view class="text">合约</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/assets')">
				<view class="image">
					<image src="../../static/timg/zichan.png" mode=""></image>
				</view>
				<view class="text">资产</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/claim')">
				<view class="image">
					<image src="../../static/timg/suopei.png" mode=""></image>
				</view>
				<view class="text">索赔</view>
			</view>
		</view>
	</view>
</template>

<script>
	import headerbox from '@/pages/header.vue'
	import {
		getuserinfo,
		baoxianYueRecord,
	} from '../../api/api.js'
	export default {
		components: {
			headerbox
		},
		data() {
			return {
				cixi: false,
				shuoming: 0,
				date: 2,
				userinfo: [],
				isBaoxianType: 1,
				baoxianList: [],
				page: 1
			}
		},
		// 上拉加载更多
		onReachBottom() {
			console.log('触发我了吗---')
			this.page++; // 增加页码  
			this.getbaoxianList(); // 获取数据
		},
		onPageScroll(e) {
			if (e.scrollTop > 0) {
				this.cixi = true
			} else {
				this.cixi = false
			}
		},
		onLoad(option) {
			this.isBaoxianType = option.isBaoxianType;
			this.getuserinfo();
			this.getbaoxianList();
		},
		methods: {
			getuserinfo() {
				getuserinfo().then(res => {
					if (res.data.status.errorCode == 0) {
						// uni.setStorageSync('userinfo', JSON.stringify(res.data.data.member))
						this.userinfo = res.data.data.member
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getbaoxianList() {
				let data = {
					type: this.isBaoxianType,
					page: this.page,
				}
				baoxianYueRecord(data).then(res => {
					if (res.data.status.errorCode == 0) {
						this.baoxianList = [...this.baoxianList, ...res.data.data.data]
					}
				}).catch(err => {
					console.log(err)
				})
			},
			copy(value) {
				uni.setClipboardData({
					data: value,
					success: function() {
						//调用方法成功
						uni.showToast({
							title: '复制成功',
							icon: 'success',
							duration: 2000
						});
					}
				})
			},
			goSwichPage(page) {
				uni.navigateTo({
					url: page
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	* {
		box-sizing: border-box;
	}

	.content {
		width: 100%;
		min-height: 100vh;
		background-color: #f1f1f7;
		color: #747474 !important;
	}

	.pages {
		padding-top: calc(calc(110rpx + 60rpx) + env(safe-area-inset-top));
		padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
	}

	.card {
		width: 89.5%;
		margin: 0 auto;
		border-radius: 20rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		word-wrap: break-word;
		margin-bottom: 30rpx;
		background-color: #fff;
		box-shadow: rgba(0, 0, 0, .35) 0px 30px 60px -30px, rgba(0, 0, 0, .35) 0px -2px 6px 0px inset;
	}

	.card-body {
		z-index: 3;
		flex: 1 1 auto;
		padding: 40rpx;
	}

	.title {
		text-align: center;
		font-size: 28rpx;
		font-weight: normal;
		color: #a5a5a5;
		line-height: 40rpx;
	}

	.title1 {
		text-align: center;
		font-size: 40rpx;
		font-weight: bold;
		color: #2a2a2a;
		padding-top: 8rpx;
		line-height: 48rpx;
	}

	.filter-section {
		width: 89.5%;
		margin: 20rpx auto;
		margin-top: 60rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.shaixuan {
		width: 47.5%;
		text-align: center;

		.label {
			margin-bottom: 20rpx;
			font-size: 28rpx;
			line-height: 48rpx;
			color: #747474;
		}
	}

	#description {
		display: block;
		width: 100%;
		padding: 15rpx 90rpx 15rpx 30rpx;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 1.5;
		color: #212529;
		background-color: #fff;
		background-image: url('../../static/timg/xiala.svg');
		background-repeat: no-repeat;
		background-position: right 30rpx center;
		background-size: 32rpx 24rpx;
		border: 2rpx solid #ced4da;
		border-radius: 10rpx;
		appearance: none;
	}

	h4 {
		font-size: 36rpx;
		line-height: 46rpx;
		font-weight: 700;
		color: #1b1b1b;
		margin-bottom: 10rpx;
	}

	.footer-bar {
		background-color: rgba(255, 255, 255, 0.95);
		padding: 0px 20rpx;
		position: fixed;
		bottom: 0px;
		left: 0px;
		right: 0px;
		z-index: 98;
		backdrop-filter: blur(20rpx);
		display: flex;
		text-align: center;
		transition: all 250ms ease;
		height: calc(120rpx + env(safe-area-inset-bottom));
		box-shadow: 0 -10rpx 10rpx 0 rgba(0, 0, 0, 0.04);
	}

	.footer-bar.footer-bar-detached {
		border-radius: 40rpx;
		left: 20rpx !important;
		right: 20rpx !important;
		bottom: 30rpx !important;
		box-shadow: 0 0px 30rpx 0 rgba(0, 0, 0, 0.1) !important;
		height: 120rpx !important;
	}

	.fbitem {
		color: #818181;
		position: relative;
		flex: 1 1 auto;
		padding-top: 24rpx;

		.image {
			height: 48rpx;
			margin-top: -4rpx;

			image {
				width: 36rpx;
				height: 36rpx;
			}
		}

		.text {
			height: 48rpx;
			margin-top: -6rpx;
			font-size: 24rpx;
			opacity: 0.7;
			color: #818181;
		}
	}

	.cardTow {
		width: 89.5%;
		margin: 0 auto;
		padding: 20px 0;
		border-radius: 20rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		word-wrap: break-word;
		background-color: #fff;
		box-shadow: rgba(0, 0, 0, .35) 0px 30px 60px -30px, rgba(0, 0, 0, .35) 0px -2px 6px 0px inset;
	}

	#nav_content_list {
		font-size: 28rpx;
		padding: 20px 0;
	}

	.titleTow {
		color: #333;
	}

	.nav_content_list {
		display: flex;
		text-align: center;
		min-height: 60rpx;
	}

	#nav_content_list .title {
		font-weight: bold;
	}

	.nav_content_list view {}

	.nav_content_list .view1 {
		width: 20%;
	}

	.nav_content_list .view2 {
		width: 30%;
		text-align: center;
	}

	.nav_content_list .view3 {
		width: 50%;
		text-align: center;
	}

	.nav_content_list .view4 {
		width: 25%;
	}
</style>